<?php

class Products_salesController extends AdminController {

    /**
     * @return array action filters
     */
    public function filters() {
        return array(
            'accessControl', // perform access control for CRUD operations
        );
    }

    /**
     * Displays a particular model.
     * @param integer $id the ID of the model to be displayed
     */
    public function actionView() {
        $model = new ecom_transaction('search_sales');
        $model->unsetAttributes();  // clear any default values
        if (isset($_GET['ecom_transaction'])) {
            $model->attributes = $_GET['ecom_transaction'];
            if (isset($_GET['ecom_transaction']['transaction_start_date']) && isset($_GET['ecom_transaction']['transaction_end_date'])) {
                if ($_GET['ecom_transaction']['transaction_start_date'] != '' && $_GET['ecom_transaction']['transaction_end_date'] != '') {
                    $model->transaction_start_date = $_GET['ecom_transaction']['transaction_start_date'];
                    $model->transaction_end_date = $_GET['ecom_transaction']['transaction_end_date'];
                }
            }
        }


        $this->render('view', array(
            'model' => $model,
        ));
    }
    
    public function actionReport() {
        $model = new ecom_transaction('search_monthly');
        $model->unsetAttributes();  // clear any default values
        
        $this->render('view', array(
            'model' => $model,
        ));
    }

    /**
     * Performs the AJAX validation.
     * @param CModel the model to be validated
     */
    protected function performAjaxValidation($model) {
        if (isset($_POST['ajax']) && $_POST['ajax'] === 'site-support-form') {
            echo CActiveForm::validate($model);
            Yii::app()->end();
        }
    }

}
